package es.upm.gib.mappingAPI2;


/**
 *
 * This class represents a Restriction for a Path
 */

public class Restriction{
    //=======================================================================
    //ATTRIBUTES
    //=======================================================================

    /**
     * The different values that the attributes op and range can take
     */
    public enum Operator{EQUAL,NOT_EQUAL,LESS,LESS_EQUAL,GREATER,GREATER_EQUAL}
    public enum Range{STRING,INTEGER,FLOAT, INSTANCE}

    private Operator op;
    private String value;
    private Range range;

    //=======================================================================
    //CONSTRUCTORS
    //=======================================================================

    /**
     * Creates an empty restriction
     */
    public Restriction(){}

    /**
     * Creates a Restriction using Operator, value (Operand) and range given as parameters
     *
     * @param op Operator
     * @param value Value of restriction
     * @param range type of restriction (Integer,Double,String,Instance
     */
    public Restriction(Operator op, String value, Range range){
        setOp(op);
        setValue(value);
        setRange(range);
    }

    //=======================================================================
    //PUBLIC METHODS
    //=======================================================================

    /**
     * This method retrieves the operator of the restriction
     * @return operator
     */
    public Operator getOp() {
        return op;
    }

    /**
     * This method sets the operator of the restriction
     *
     * @param op name of the author
     */
    public void setOp(Operator op) {
        this.op = op;
    }

    /**
     * This method retrieves the value of the restriction
     * @return operator
     */
    public String getValue() {
        return value;
    }

    /**
     * This method sets the value of the restriction
     *
     * @param value name of the author
     */
    public void setValue(String value) {
        this.value = value;
    }

    /**
     * This method retrieves the range of the restriction.
     *
     * @return range
     */
    public Range getRange() {
        return range;
    }

    /**
     * This method sets the range of the restriction
     *
     * @param range range of the restriction
     */
    public void setRange(Range range) {
        this.range = range;
    }

    @Override
    public String toString() {
        return op + "(" + value + "/" + range + ")";
    }
}
